/*
* INSANE - Interactive Structural Analysis Environment
*
* Copyright (C) 2003-2005
* Universidade Federal de Minas Gerais
* Escola de Engenharia
* Departamento de Engenharia de Estruturas
* 
* Author's email :    insane@dees.ufmg.br
* Author's website :  http://www.dees.ufmg.br/insane
* 
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
package br.ufmg.dees.insane.model.femModel.element;

import java.util.ArrayList;

import br.ufmg.dees.insane.materialMedia.degeneration.Degeneration;
import br.ufmg.dees.insane.materialMedia.degeneration.Representation;
import br.ufmg.dees.insane.materialMedia.degeneration.Solid;
import br.ufmg.dees.insane.materialMedia.materialPoint.MaterialPoint;
import br.ufmg.dees.insane.util.INaturalCoords;
import br.ufmg.dees.insane.util.IVector;
import br.ufmg.dees.insane.util.numericalIntegration.IntegrationPoint;
import br.ufmg.dees.insane.util.numericalIntegration.VolumeGaussPoint;

/**
*A class representing a tetrahedral parametric element.<p>
*
*@author Lucas, Marcelo & Pitangueira, Roque
*@version 1.0
*@since June 2004
*/

public class Tetrahedral extends ParametricElement
{
	private final static long serialVersionUID = 1L;
	
    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.model.femModel.element.Element#addDegeneration(java.util.ArrayList)
     */
    public void addDegeneration(Degeneration dg){
        Degeneration dgn = new Solid();
        dgn.setOriginalLabel(dg.getOriginalLabel());
        
        for(int i = 0; i<dg.getMaterialPoints().size(); i++){
            try {
                dgn.add((MaterialPoint)(dg.getMaterialPoint(i)).clone());
            }
            catch (CloneNotSupportedException e) {
                e.printStackTrace();
            }
        }
        
        this.degenerations.add(dgn);
    }
    
	/* (non-Javadoc)
	 * @see br.ufmg.dees.insane.model.femModel.element.Element#createDegenerations()
	 */
	public void initDegenerations()
	{
		int k = 1;
		IntegrationPoint ip = new VolumeGaussPoint();
		for(int i = 0; i < (this.integrationOrder.getXiIntegOrder()); i++)
		{
		    Representation representation = new Representation();
			INaturalCoords nc = new INaturalCoords();
			nc.setCsi1(ip.getCoord(this.integrationOrder.getXiIntegOrder()-1,(4*i)));
			nc.setCsi2(ip.getCoord(this.integrationOrder.getXiIntegOrder()-1,(4*i+1)));
			nc.setCsi3(ip.getCoord(this.integrationOrder.getXiIntegOrder()-1,(4*i+2)));
			representation.setNaturalcoords(nc);
			representation.setWeight(ip.getWeight(this.integrationOrder.getXiIntegOrder()-1,i));
			representation.setAnalysisModel(this.getAnalysisModel());
			representation.setCm(this.getConstitutiveModel());
			((Degeneration)this.getDegenerations().get(k-1)).setRepresentation(representation);
            ((Degeneration)this.getDegenerations().get(k-1)).setLabel("IP-"+k);
            k++;
		}		
	}
	
	/** Return the element integration coefficient.
	*@return 1/6.
	*/
	public double getElmCoefficient() 
	{
		return (0.16666666666666667);
	}

	@Override
	public IVector extrapolatesToNodes(ArrayList a, ArrayList d) {
		// TODO Auto-generated method stub
		return null;
	}

}
